package com.dubito.composewidgets.utils

import android.content.Context
import android.net.Uri
import androidx.core.content.FileProvider
import com.dubito.composewidgets.R
import java.io.File

/**
 * author: LiLiang
 * createTime: 2022/10/5-8:43
 * remark:
 **/
class ComposeFileProvider : FileProvider(R.xml.filepaths) {
    companion object {
        fun getImageUri(context: Context): Uri {
            val directory = File(context.cacheDir, "images")
            directory.mkdirs()
            val file = File.createTempFile("selected_image_", ".jpg", directory)
            val authority = context.packageName + ".fileprovider"
            return getUriForFile(context, authority, file)
        }
    }
}